package com.ruoyi.web.core.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.net.DatagramSocket;

@Component
@EnableScheduling
public class SpnUdpSender {
    @Autowired
    private DatagramSocket socket;

    @Autowired
    private UdpService udpService;

    /**
     * 每 1 分钟执行一次发送操作
     * ping 以及 告警
     */
    @Scheduled(fixedRate = 60000)
    public void sendData() {
        udpService.sendAndReceive(socket);
    }
}